package ynu.edu.controller;

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import ynu.edu.common.controller.LogicController;
import ynu.edu.dao.*;
import ynu.edu.entity.*;
import ynu.edu.service.BusinessService;


@Api(tags = "商家实体的控制器")
@RestController
@RequestMapping("/business")
public class BusinessController extends LogicController<BusinessService, BusinessDao, Business,Long> {
    public BusinessController(@Autowired BusinessService service){
        super(service);
    }
    @GetMapping("/getAllMyItem")
    public List<Item> getAllMyItem(@RequestParam("name")String name){
        return getService().getAllMyItem(name);
    }
    @GetMapping("/getAllMyOrder")
    public List<Order1> getAllMyOrder(@RequestParam("shopId")Long shopId){
        return getService().getAllMyOrder(shopId);
    }
    @PostMapping("/cancelOrder")
    public Order1 cancelOrder(@RequestParam("shopId")Long shopId,@RequestParam("orderId")Long orderId){
        return getService().cancelOrder(shopId,orderId);
    }
    @PostMapping("/confirmOrder")
    public Order1 confirmOrder(@RequestParam("shopId")Long shopId,@RequestParam("orderId")Long orderId){
        return getService().confirmOrder(shopId,orderId);
    }
    @PostMapping("/upItem")
    public ShopItem upItem(@RequestParam("name")String name,@RequestParam("shopId")Long shopId,
                           @RequestParam("itemId")Long itemId,@RequestParam("price")Double price){
        return getService().upItem(name,shopId,itemId,price);
    }
    @PostMapping("/createItem")
    public Item createItem(@RequestParam("name")String name,@RequestParam("itemName")String itemName){
        return getService().createItem(name,itemName);
    }
    @PostMapping("/createShop")
    public Shop createShop(@RequestParam("name")String name,@RequestParam("shopName")String shopName){
        return getService().createShop(name,shopName);
    }
    @GetMapping("/getAllMyShop")
    public List<Shop> getAllMyShop(@RequestParam("name")String name){
        return getService().getAllMyShop(name);
    }
    @PostMapping("/login")
    public Business login(@RequestParam("name")String name, @RequestParam("password")String password){
        return getService().login(name,password);
    }
    @PostMapping("/register")
    public Business register(@RequestParam("name")String name,@RequestParam("password")String password){
        return getService().register(name,password);
    }

}
